/*
 * Copyright (C) 2012 Caldia Apps.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.caldia.android.frameworkG1.controller;
import java.util.Set;

import org.caldia.android.frameworkG1.activity.AbstractActivity;
import org.caldia.android.frameworkG1.application.Application;
import org.caldia.android.frameworkG1.application.MessagingController;
import org.caldia.android.frameworkG1.fragment.TopFragment;
import org.caldia.android.frameworkG1.preference.MyPreference;

import android.app.Activity;
import android.support.v4.app.Fragment;

/**
 * モード管理マネージャの親クラス
 *
 * @author k-matsuda@caldia.org
 *
 */
public abstract class ModeManager implements ITransitionManager {

	public static final int INVALID_VALUE = -1;

	/**
	 * アプリケーション
	 */
	private final Application mApplication;

	/**
	 * 画面遷移マネージャ
	 */
	private final ITransitionManager mTransitionManager;

	/**
	 * コンストラクタ
	 *
	 * @param application
	 *            アプリケーション
	 */
	public ModeManager(final Application application) {
		mApplication = application;
		mTransitionManager = TransitionManager.getInstance(application, -1);
	}

	protected ITransitionManager getTransitionManager() {
		return mTransitionManager;
	}

	protected Application getApplication() {
		return mApplication;
	}

	@Override
	public int getActivityNo(final Class<? extends Activity> cls,
			final int logNo) {
		// TODO Auto-generated method stub
		return INVALID_VALUE;
	}

	@Override
	public int getFragmentNo(final Class<? extends Fragment> cls,
			final int logNo) {
		// TODO Auto-generated method stub
		return INVALID_VALUE;
	}

	@Override
	public int getNextFragmentNo(final int currentNo, final int logNo) {
		// TODO Auto-generated method stub
		return INVALID_VALUE;
	}

	@Override
	public int getPreviousFragmentNo(final int currentNo, final int logNo) {
		// TODO Auto-generated method stub
		return INVALID_VALUE;
	}

	@Override
	public void setMode(final int modeNo, final int logNo) {
		// TODO Auto-generated method stub

	}

	@Override
	public int getMode(final int logNo) {
		// TODO Auto-generated method stub
		return INVALID_VALUE;
	}

	@Override
	public void addActivity(final int activityNo,
			final Class<? extends Activity> cls, final int logNo) {
		// TODO Auto-generated method stub

	}

	@Override
	public void addFragment(final int fragmentNo,
			final Class<? extends Fragment> cls, final int logNo) {
		// TODO Auto-generated method stub

	}

	@Override
	public int getNextActivityNo(final int currentNo, final int logNo) {
		// TODO Auto-generated method stub
		return INVALID_VALUE;
	}

	@Override
	public int getPreviousNo(final int currentNo, final int logNo) {
		// TODO Auto-generated method stub
		return INVALID_VALUE;
	}

	@Override
	public void startMode(final int mode, final ControllerListener l,
			final int logNo) {
		// TODO Auto-generated method stub

	}

	@Override
	public TopFragment getFragment(final int fragmentNo, final int logNo) {

		// フラグメント名
		final String fragmentName = getTransitionManager().getFragmentName(
				fragmentNo, logNo);
//		CLog.dt(this, logNo, "フラグメント生成 === " + fragmentNo + " >> "
//				+ fragmentName);

		try {
			final Class<?> cls = Class.forName(fragmentName);
			return (TopFragment) cls.newInstance();

		} catch (final Exception e) {
			e.printStackTrace();
		}

		return null;
	}

	@Override
	public void setFragmentActivity(
			final Class<? extends AbstractActivity> activity, final int logNo) {
		// TODO Auto-generated method stub

	}

	@Override
	public String getFragmentActivityName(final int logNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public MessagingController getMessagingController(final int logNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public MyPreference getPreference(final int logNo) {

		return MyPreference.getInstance(getApplication());

	}

	@Override
	public String getActivityName(final int activityNo, final int logNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getFragmentName(final int fragmentNo, final int logNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Application getApplication(final int logNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Set<ControllerListener> getMessagingListeners(final int logNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Set<ControllerListener> getMessagingListeners(
			final ControllerListener l, final int logNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void addMessagingListener(final ControllerListener listener) {
		// TODO Auto-generated method stub

	}

	@Override
	public void removeMessagingListener(final ControllerListener l) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean hasNextFragment(final int currentNo, final int logNo) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean hasNextActivity(final int currentNo, final int logNo) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean hasPreviousFragment(final int currentNo, final int logNo) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean hasPreviousActivity(final int currentNo, final int logNo) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void moveToNextActivity(final int currentNo,
			final ControllerListener l, final int logNo) {
		// TODO Auto-generated method stub
	}

	@Override
	public void moveToPreviousActivity(final int currentNo,
			final ControllerListener l, final int logNo) {
		// TODO Auto-generated method stub
	}

	@Override
	public void setNextTrasition(final int currentNo, final int nextNo,
			final int logNo) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setPrevioutTrasiton(final int currentNo, final int previousNo,
			final int logNo) {
		// TODO Auto-generated method stub

	}

	@Override
	public void addModeManager(final int modeNo,
			final Class<? extends ModeManager> modeManager, final int logNo) {
		// TODO Auto-generated method stub

	}

	@Override
	public ModeManager getModeManager(final int modeNo, final int logNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getModeNo(final Class<? extends ModeManager> modeManager,
			final int logNo) {
		// TODO Auto-generated method stub
		return INVALID_VALUE;
	}

	@Override
	public void startActivity(final int activityNo, final ControllerListener l,
			final int logNo) {
		// TODO Auto-generated method stub

	}

	/**
	 * フラグメント番号に変換する
	 *
	 * @param cls
	 *            変換元フラグメントクラス
	 * @param logNo
	 *            トラッキング用番号
	 * @return フラグメント番号
	 */
	protected int convertNo(final Class<? extends Fragment> cls, final int logNo) {
		return mTransitionManager.getFragmentNo(cls, logNo);
	}

	@Override
	public int getNo(final Object obj) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void sendOnCreateMessage(final Object obj) {
		// TODO Auto-generated method stub

	}

	@Override
	public void sendOnResumeMessage(final Object obj) {
		// TODO Auto-generated method stub

	}

	@Override
	public void sendOnStopMessage(final Object obj) {
		// TODO Auto-generated method stub

	}

	@Override
	public void sendOnDestroyMessage(final Object obj) {
		// TODO Auto-generated method stub

	}
}
